package com.baizan.daka.ui.activity

import android.content.Context
import android.content.Intent
import com.baizan.daka.base.BasePageListActivity
import com.baizan.daka.mvp.model.bean.MyTeam
import com.baizan.daka.mvp.model.bean.UserCaplitalDes
import com.baizan.daka.mvp.model.bean.UserTeam
import com.baizan.daka.net.BasePageResponse
import com.baizan.daka.net.bean.UserTeamDesBean
import com.baizan.daka.ui.adapter.MyTeamAdapter
import com.baizan.daka.ui.contract.MyTeamContract
import com.baizan.daka.ui.presenter.MyTeamPresenter
import com.dianzan.daka.R
import kotlinx.android.synthetic.main.act_my_team.*

class MyTeamActivity : BasePageListActivity<MyTeamPresenter, MyTeamAdapter>(), MyTeamContract.View {

    companion object {
        fun start(context: Context) {
            val intent = Intent(context, MyTeamActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun onRefresh() {
    }

    override fun onLoadMore() {
    }

    override fun initAdapter(): MyTeamAdapter = MyTeamAdapter()

    override fun initPresenter(): MyTeamPresenter = MyTeamPresenter(this)

    override fun initView() {

    }

    override fun start() {
        presenter?.loadData(mCurrentPageNo)
    }

    override fun layoutId(): Int = R.layout.act_my_team
    override fun loadSuccess(date: List<MyTeam>) {
        date?.let {
            adapter?.setNewData(it)
            var sum: Int = 0
            for (item in it) {
                sum += item.teamNumber
            }
            my_team_title.text = "团队总人数：${sum}人"
        }
        adapter?.loadMoreEnd();
    }

    override fun loadTeamDes(data: BasePageResponse<UserTeamDesBean>) {
    }

    override fun loadTeamDesFail() {
    }

}